File Sharing Service and SMB Protocol Wiki
Welcome to the File Sharing Service and SMB Protocol Wiki File Sharing Service and SMB Protocol 'File Sharing' Computer networks allow you to share files with friends, family, coworkers and customers. Before the Internet and home networks became popular, files were often shared using floppy disks. Nowadays, some people still use CD-ROM / DVD-ROM disks and USB keys for transferring their photos and videos, but networks give you more flexible options. Network file sharing is the process of copying files from one computer to another using a live network connection. This article describes the different methods and networking technologies available to help you share files. Microsoft Windows (and other personal computer operating systems) contain built-in features for file sharing. For example, Windows file folders can be shared across a local area network (LAN) or the Internet using any of several methods. You can also set up security access restrictions that control who can obtain the shared files. With this method of sharing, you can decide who will be able to make changes to the files you share, and what kind of changes (if any) they can make to them. You do this by setting sharing permissions. Sharing permissions can be granted to an individual or to a group of users on the same network. For example, you might allow some people to only view your shared files, while allowing others to both view and change them. People you share with will be able to see only those folders that you have shared with them. You can also use this method of sharing as a way to access your shared files when you are using another computer, since any files you share with other people are also visible to you from another computer. File sharing is the public or private sharing of computer data or space in a network with various levels of access privilege. While files can easily be shared outside a network (for example, simply by handing or mailing someone your file on a diskette), the term file sharing almost always means sharing files in a network, even if in a small local area network. File sharing allows a number of people to use the same file or file by some combination of being able to read or view it, write to or modify it, copy it, or print it. Typically, a file sharing system has one or more administrators. Users may all have the same or may have different levels of access privilege. File sharing can also mean having an allocated amount of personal file storage in a common file system. File sharing has been a feature of mainframe and multi-user computer systems for many years. With the advent of the Internet, a file transfer system called the File Transfer Protocol (FTP) has become widely-used. FTP can be used to access (read and possibly write to) files shared among a particular set of users with a password to gain access to files shared from an FTP server site. Many FTP sites offer public file sharing or at least the ability to view or copy files by downloading them, using a public password (which happens to be "anonymous"). Most Web site developers use FTP to upload new or revised Web files to a Web server, and indeed the World Wide Web itself can be thought of as large-scale file sharing in which requested pages or files are constantly being downloaded or copied down to the Web user. 'Server Message Block (SMB) Protocol ' SMB, which stands for Server Message Block, is a protocol for sharing files, printers, serial ports, and communications abstractions such as named pipes and mail slots between computers. The earliest document I have on the SMB protocol is an IBM document from 1985. It is a copy of an IBM Personal Computer Seminar Proceedings from May 1985. It contains the IBM PC Network SMB Protocol. The next document I have access to is a Microsoft/Intel document called Microsoft Networks/OpenNET-FILE SHARING PROTOCOL '''from 1987. The protocol was subsequently developed further by Microsoft and others. Many of the documents that define the SMB protocol(s) are available at ftp.microsoft.com in the SMB documentation area. '''SMB is a client server, request-response protocol. The diagram to the left illustrates the way in which SMB works. The only exception to the request-response nature of SMB (that is, where the client makes requests and the server sends back responses) is when the client has requested opportunistic locks (oplocks) and the server subsequently has to break an already granted oplock because another client has requested a file open with a mode that is incompatible with the granted oplock. In this case, the server sends an unsolicited message to the client signalling the oplock break. Servers make file systems and other resources (printers, mailslots, named pipes, APIs) available to clients on the network. Client computers may have their own hard disks, but they also want access to the shared file systems and printers on the servers. Clients connect to servers using TCP/IP (actually NetBIOS over TCP/IP as specified in RFC1001 and RFC1002), NetBEUI or IPX/SPX. Once they have established a connection, clients can then send commands (SMBs) to the server that allow them to access shares, open files, read and write files, and generally do all the sort of things that you want to do with a file system. However, in the case of SMB, these things are done over the network. 'Server Message Block (SMB) Protocol' The Server Message Block protocol, or "SMB", is a remote file access protocol originally specified by Microsoft, IBM, and Intel. It's also referred to as the Common Internet File System, or "CIFS". It's one of the protocols most commonly used by DOS and Windows machines to access files on a file server. Current versions of Windows, and some older versions of Windows, include both client and server code for SMB/CIFS; clients and servers were also available for older versions of DOS and Windows, and for OS/2. The Samba server is the most commonly used SMB/CIFS server on UN*X systems; Linux, FreeBSD, and Mac OS X include clients for SMB/CIFS allowing those systems to access files on SMB/CIFS servers as if they were local files. Specifications for implementations of the NetBIOS services, which are what the NetBEUI protocol implemented, also exist for UDP and TCP; the specifications for that are in RFC 1001 and RFC 1002, and the protocols specified by that are the NetBIOS Name Service (NBNS), NetBIOS Datagram Service (NBDS), and the NetBIOS Session Service (NBSS) protocols. NetBIOS-over-TCP is probably now the most common form of NetBIOS used by SMB. Specifications for SMB over the MAP/TOP protocol suite, based on the IsoProtocolFamily, also exist. NetBIOS is also supported in at least two forms over the NovellProtocolFamily. SMB can now run directly atop TCP port 445, without using any of the NetBIOS services (other than a vestigial version of the session service, simplified to only provide packet boundaries over a TCP data stream). Windows 2000 might have been the first version of Windows to implement this. At least at one point, a number of specifications for various dialects of SMB could be found in a directory on the Microsoft FTP site. The closest thing to an "official" specification for the current version of SMB/CIFS is the SNIA Common Internet File System Technical Reference, but that doesn't describe all the protocol features used by Microsoft clients and supported by Microsoft servers. Understanding Samba Because Linux and Windows have such different file systems, you can’t create a Linux file server simply by granting Windows users access to Linux directories.Windows client computers wouldn’t be able to access files in the Linux directories. There are just too many differences between the file systems —these, for example: Linux file names are case-sensitive; Windows file names are not. For example, in Windows, File1.txt and file1.txt are the same file. In Linux, they are different files. Linux file names can contain periods. In Windows, only one period is allowed — and it separates the file name from the file extension. Windows has file attributes such as Read-only and Archive. Linux doesn’t have these. More fundamentally, Windows networking uses a protocol called SMB, which stands for Server Message Block, to manage the exchange of file data between file servers and clients. Linux doesn’t have SMB support built in.That’s why Samba is required. Samba is a program that mimics the behavior of a Windows-based file server by implementing the SMB protocol. So when you run Samba on a Linux server, the Windows computers on your network see the Linux server as if it were Windows server. Samba is a freely available SMB server for UNIX, OpenVMS (recently ported and maybe not very stable) developed by Andrew Tridgell and maintained by a loosely knit group of people all over the world. Samba runs on a great many UNIX variants (Linux, Solaris, SunOS, HP-UX, ULTRIX, DEC OSF/1, Digital UNIX, Dynix (Sequent), IRIX (SGI), SCO Open Server, DG-UX, UNIXWARE, AIX, BSDI, NetBSD, NEXTSTEP, A/UX, etc). Samba implements the NT LM 0.12 protocol dialect. Samba can now participate in a domain (both as a PDC and a Member of a domain), and it can participate in browsing and can be a browse master. Samba can also process logon requests for Windows 95 systems Samba implements user level security, but shares can be public where access is mapped to the owner etc of the share. Like a Windows server, Samba works by creating and designating certain directories as shares. A share is simply a directory that is made available to other users via the network. Each share has the following elements: � Share name: The name by which the share is known over the network. Share names should be eight-character share names whenever possible. � Path: The path to the directory on the Linux computer that’s being shared, such as \Users\Doug. � Description: A one-line description of the share. � Access: A list of users or groups who have been granted access to the share. Samba also includes a client program that lets a Linux computer access Windows file servers. Installing Samba If you didn’t install Samba when you installed Linux, you’ll have to install it now. There are two basic ways to do that. One is to use Red Hat’s GNOMEbased package management tool to install Samba. Just insert the Red Hat distribution CD in the CD drive, and click Yes when you’re asked whether you want to run the autorun program. Then, when the Package Management window appears, select the Windows File Server group, which installs the Samba packages for you. Beware: One sure way to render a Samba installation absolutely useless is to enable the default Linux firewall settings on the computer that runs Samba. The Linux firewall is designed to prevent users from accessing network services such as Samba. It’s designed to be used between the Internet and your local network, not between Samba and your local network. Although it is possible to configure the firewall to allow access to Samba only to your internal network, a much better option is to run the firewall on a separate computer. That way the firewall computer can concentrate on being a firewall, the fileserver computer can concentrate on serving up files, and peace can reign in the valley once again. Samba is a suite of Unix applications that speak the SMB (Server Message Block) protocol. Many operating systems, including Windows and OS/2, use SMB to perform client-server networking. By supporting this protocol, Samba allows Unix servers to get in on the action, communicating with the same networking protocol as Microsoft Windows products. Thus, a Samba-enabled Unix machine can masquerade as a server on your Microsoft network and offer the following services: *Share one or more filesystems *Share printers installed on both the server and its clients *Assist clients with Network Neighborhood browsing *Authenticate clients logging onto a Windows domain *Provide or assist with WINS name server resolution Samba is the brainchild of Andrew Tridgell, who currently heads the Samba development team from his home of Canberra, Australia. The project was born in 1991 when Andrew created a fileserver program for his local network that supported an odd DEC protocol from Digital Pathworks. Although he didn't know it at the time, that protocol later turned out to be SMB. A few years later, he expanded upon his custom-made SMB server and began distributing it as a product on the Internet under the name SMB Server. However, Andrew couldn't keep that name -- it already belonged to another company's product -- so he tried the following Unix renaming approach: grep -i 's.*m.*b' /usr/dict/words And the response was: salmonberry samba sawtimber scramble Thus, the name "Samba" was born. Which is a good thing, because our marketing people highly doubt you would have picked up a book called "Using Salmonberry"! Today, the Samba suite revolves around a pair of Unix daemons that provide shared resources -- or shares -- to SMB clients on the network. (Shares are sometimes called s''ervices'' as well.) These daemons are: ;smbd : A daemon that allows file and printer sharing on an SMB network and provides authentication and authorization for SMB clients. ;nmbd : A daemon that looks after the Windows Internet Name Service (WINS), and assists with browsing. Samba is currently maintained and extended by a group of volunteers under the active supervision of Andrew Tridgell. Like the Linux operating system, Samba is considered Open Source software ''(OSS) by its authors, and is distributed under the GNU General Public License (GPL). Since its inception, development of Samba has been sponsored in part by the Australian National University, where Andrew Tridgell earned his Ph.D.[1] In addition, some development has been sponsored by independent vendors such as Whistle and SGI. It is a true testament to Samba that both commercial and non-commercial entities are prepared to spend money to support an Open Source effort. At the time of this printing, Andrew had completed his Ph.D. work and had joined San Francisco-based LinuxCare. Microsoft has also contributed materially by putting forward its definition of SMB and the Internet-savvy Common Internet File System (CIFS), as a public Request for Comments (RFC), a standards document. The CIFS protocol is Microsoft's renaming of future versions of the SMB protocol that will be used in Windows products -- the two terms can be used interchangeably in this book. Hence, you will often see the protocol written as "SMB/CIFS." Starting and stopping Samba Before you can use Samba, you must start its two daemons, smbd and nmbd. Both can be started at once by starting the smb service. From a command shell, use this command: ''service smb start Whenever you make a configuration change such as adding a new share or a creating a new Samba user, you should stop and restart the service with these commands: service smb restart If you prefer, you can stop and start the service with separate commands: service smb stop service smb start If you’re not sure that Samba is running, enter this command: service smb status You’ll get a message indicating whether the smbd and nmbd daemons are running. To configure Samba to start automatically when you start Linux, use this command: chkconfig –level 35 smb on To make sure the chkconfig command worked right, enter this command: chkconfig –list smb You should see output similar to the following: Smb'' 0:off 1:off 2:off 3:on 4:off 5:on 6:off'' Category:Browse